/*
 * @Author: sunzhijun 
 * @Date: 2019-04-18 18:54:35 
 * @Last Modified by: sunzhijun
 * @Last Modified time: 2019-10-15 18:55:02
 */
import React from 'react';
import { base } from 'nc-lightapp-front'
const { NCCheckbox } = base;
import {render, connect} from 'src/hrpub/common/frame';
import ReferSearch from 'src/hrpub/common/components/referSearch/org';
import NCBackBtn from 'src/hrpub/common/components/hr-back';
import './index.less';

const Wrapper = render({
    actions: {
        // headerAct: HeaderAction,
        // btnAct: ButtonAction,
        // tableAct: TableAction,
        // cardAct: CardAction
    }
})(({props, state}) => {
    const {main, action, button} = props;
    const { createButtonApp } = button;
    const { language } = main;
    return (
        <React.Fragment>
            <div className="header">
                <If condition={!main.isCardForm && !main.isSort}>
                    <ReferSearch
                        orgVal={main.orgValue}
                        getOrgData={action.headerAct.searchOrganization}
                    />
                </If>
                <If condition={main.isCardForm || main.isSort}>
                    <NCBackBtn onClick={action.headerAct.back} className="back-btn"/>
                </If>
                <If condition={!!main.pk_org}>
                    <If condition={!main.isCardForm  && !main.isSort}>
                        <div className="header-checkbox-group">
                            <NCCheckbox 
                                disabled = { main.isDisabled }
                                checked = { main.isChecked }
                                onChange = { action.headerAct.setShowOrHidden }
                                // defaultChecked={this.state.checked}
                            >
                                {/* 国际化处理： 显示子集*/}
                                {language['hi6007-000094']}
                            </NCCheckbox>
                        </div>
                    </If>
                    <div className="btn-group">
                        {createButtonApp({
                            area: 'head',//按钮注册中的按钮区域
                            buttonLimit: 1,
                            onButtonClick: (props, btncode) => action.btnAct.handleButton(props, btncode),
                            // popContainer: document.querySelector('.header-button-area')
                        })}
                    </div>
                </If>
            </div>
        </React.Fragment>
    );

});


export default connect(Wrapper);